<?php mb_internal_encoding("UTF-8"); ?>
<?php include('db.inc'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="cs" xml:lang="cs">                   
  <head>	                                   
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Language" content="cs" />                                   
    <meta name="author" content="Pavel Kohout, Petr Koula, Alexandr Krátký, Tomáš Rejdal, Martina Zemaníková" />	                       
    <meta name="keywords" content="regionální, potravina, středočeský, kraj, regionální potravina, středočeský kraj, potravina středočeský" />	                                   
    <meta name="Description" content="Semestrální práce na téma Regionální potraviny Středočeského kraje z předmětu IT CS" />	
    <meta name="robots" content="all" />	                                   
    <title>Regionální potraviny</title>	                                   
    <link rel="StyleSheet" href="css/screen.css" type="text/css" media="screen" />	                                   
    <link rel="stylesheet" href="css/tisk.css" type="text/css" media="print" />	                                   
    <base target="text" />                    
  </head>          
  <?php  
    $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");  
    mysql_select_db($db) or die ("Unable to select database!");
  ?>          
  <body >                                  
    <table class="tabulka2">                                                   
      <tr class="ost">                                                                     
        <td colspan="3"><h1>Regionální potraviny</h1></td>
      </tr>
                                            
      <tr class="ost">                                                                  
        <td colspan="3" class="osta"><br />         
		<table>                                                                                                   
            <tr class="nahoru">
		
		<td>      
		 <table class="tabulka4">
             <tr class="ost">
                           <td>
                                 Kategorie:
                           </td>
              </tr>
                       <tr class="ost">
                           <td>
                                 <a href="?filter=">Vše</a>
                           </td>
                       </tr>
                       <?php
                        mysql_query("SET NAMES UTF8");
                        mysql_query("SET CHARACTER SET UTF8");
                        $result = mysql_query("SELECT id, name FROM category") or die ("Error in query: ".mysql_error()); 
                        if (mysql_num_rows($result) > 0) { 
                            while($row = mysql_fetch_row($result)) { 
                                echo "<tr>"; 
                                echo "<td><a href=\"?filter=".$row[0]."\">".ucfirst($row[1])."</a></td>"; 
                                echo "</tr>"; 
                            } 
                        } 
                        else { 
                            // no 
                            // print status message 
                            echo "Žádné záznamy nenalezny"; 
                        } 
                        
                        // free result set memory 
                        mysql_free_result($result); 

                       ?>
            </table>
              </td>

                
                <td>                                                                                                     
                      <table>
                        <?php
                        $query = "select f.id, f.name, f.img_file, c.name as category, p.name as producer
                                  from food f inner join category c on f.category_id = c.id
                                  inner join producer p on f.producer_id = p.id ";
                        if (isset($_GET['filter']) && $_GET['filter'] !="") {
                          $query = $query."where c.id = ".$_GET['filter'];
                        }
                        $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
                        if (mysql_num_rows($result) > 0) { 
                            while($row = mysql_fetch_row($result)) { 
                                echo "<tr><td colspan=\"2\" class=\"osta44\"><a href=\"polozka.php?id=".$row[0]."\">".$row[1]."</a></td></tr>";
                                echo "<tr><td rowspan=\"2\"><img alt=\"Obrázky potravin\" src=\"images/".$row[2]."\"/></td></tr>"; 
                                echo "<tr><td class=\"nopadd57\">Kategorie: ".$row[3]."<br />"; 
                                echo "Výrobce: ".$row[4]."</td></tr><tr>
                            <td colspan=\"2\" class=\"nopadd56\"></td></tr>";               
                            } 
                        } 
                        else { 
                            // no 
                            // print status message 
                            echo "Žádné záznamy nenalezny"; 
                        } 
                        
                        // free result set memory 
                        mysql_free_result($result); 
                        mysql_close($connection);  
                        ?> 

 
                      </table>  
<br />         
                </td>                                                                                                   
          </tr>                                                                                 
          </table></td>                                                
      </tr>                                                   
      <tr>                                                                 
        <td height="2" colspan="3" class="nopadd55"></td>                                                
      </tr>                                                
      <tr>                                                                 
        <td height="8" colspan="3" align="left" class="osta"></td>                                                   
      </tr>                                                
      <tr>                                                                 
        <td align="left" height="15" colspan="2">                                                                              
          <div class="bez">                                                                                               
            <a href="http://validator.w3.org/check?uri=referer" target="_blank">                                                                                                        
              <img         src="images/valid-xhtml10.png"         alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>		&nbsp; 		                                                                                           
            <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank">                                                                                                                 
              <img src="images/vcss.gif"             alt="Ověřit CSS!" />    </a>		                                                                             
          </div>	</td>	                                                               
        <td width="60%" colspan="1" class="ostat">                                                                            
          <a href="javascript:window.print()" class="odkaz2">Vytisknout</a>                                                                            
          <span class="normal_maly"> |                                                                              
          </span>                                                                            
          <a href="prohlaseni.php" target="_self" class="odkaz2">Prohlášení o přístupnosti</a>  </td>                                                
      </tr>                                  
    </table>                    
  </body>
</html>
